home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 966 b | 58 lines | [TEXT/CWIE] |
- // HeapLink.cp
-
- #ifndef HeapLink_h
- #include "HeapLink.h"
- #endif
- #ifndef Heap_h
- #include "Heap.h"
- #endif
- #ifndef Swap_h
- #include "Swap.h"
- #endif
- #ifndef Heap_h
- #include "Heap.h"
- #endif
-
- template < class Element >
- HeapLink<Element>::HeapLink( Element *e )
- : heap( 0 ),
- body( e ),
- path( 0 )
- {
- children[0] = 0;
- children[1] = 0;
- }
-
- template < class Element >
- HeapLink<Element>::~HeapLink()
- {
- if ( heap != 0 )
- heap->Remove( *this );
- Assert( heap == 0 );
- }
-
- template < class Element >
- void HeapLink<Element>::SwapWith( LinkType& r )
- {
- Assert( heap == r.heap );
-
- Swap( path, r.path );
- Swap( children[0], r.children[0] );
- Swap( children[1], r.children[1] );
- }
-
- template < class Element >
- bool HeapLink<Element>::operator<=( const LinkType& r ) const
- {
- Assert( heap == r.heap );
- Assert( heap != 0 );
-
- Comparator below( heap->Below() );
- Assert( below != 0 );
-
- Assert( !Null() );
- Assert( !r.Null() );
-
- return (body->*below)(*r.body);
- }
-